import org.springframework.web.bind.annotation.*
import javax.annotation.Resource

@RestController
@RequestMapping("/users")
class UserController {
    @Resource
    private lateinit var userService: UserService

    @PostMapping
    fun saveUser(@RequestBody user: User): Int {
        return userService.saveUser(user)
    }

    @GetMapping("/{id}")
    fun getUserById(@PathVariable id: Long): User? {
        return userService.getUserById(id)
    }

    @GetMapping
    fun getAllUsers(): List<User> {
        return userService.getAllUsers()
    }
}    